import reqAddress from '../req-set.js'

let state = {
	itemInfoObj: "",
	item_taokouling:"",
}
let mutations = {
	setItemInfoObj(state, v) {
		state.itemInfoObj = v
	},
	setItem_TaoKoLing(state,v){
		state.item_taokouling =v
	}
}
let actions ={
	reqItemInfoObj(store,param){
		console.log(param.gid)
		return new Promise((resolve,reject)=>{
			uni.request({
				method:'GET',
				url:`${reqAddress}/goods/?gid=${param.gid}`,
				success: (resp) => {
					
					console.log(resp.data.results.n_tbk_item[0])
					store.commit('setItemInfoObj',resp.data.results.n_tbk_item[0])
					
					resolve('成功')
				},
				fail: (err) => {
					reject('失败')
				}
			})
		})
	},
	reqItemTaoKoLing(store,param){
		return new Promise((resolve,reject)=>{
			uni.request({
				url:`${reqAddress}/sign?url=${param.url}`,
				method:"GET",
				success: (resp) => {
					console.log(resp.data.data.model)
					store.commit("setItem_TaoKoLing",resp.data.data.model)
					resolve(resp.data.data.model)
				}
			})
		})
	}
}
let itemInfo_idx={
	state,
	mutations,
	actions
}
export default itemInfo_idx